package com.wangzhen.abstractroutingdatasource.controller;

import com.wangzhen.abstractroutingdatasource.entity.User;
import com.wangzhen.abstractroutingdatasource.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Arrays;

/**
 * @author dell
 * @since 2021/7/6 10:43
 */
@Controller
@RequestMapping(path = "/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(path = "/test")
    public void test() {
        for (int i = 0; i < 10; i++) {
            User user = new User();
            user.setName("name_" + i);
            // 插入数据
            userService.insertUser(user);
            // 查询数据
            User byId = userService.findById(user.getId());
        }
    }
}
